<!-- 设备管理-设备列表页面 -->
<template>
  <div class="app-container" style="margin: 0">
    <px-form v-show="showSearch" ref="queryRef" class="custom-form-ui" :model="queryParams" :inline="true" label-width="90px">
      <!-- <px-form-item label="固废代码">
        <px-select
          v-model="queryParams.wasteCode"
          placeholder="请选择固废代码"
          clearable
          style="width: 240px"
          filterable
          @change="setreceiveCompanyCode"
        >
          <px-option v-for="dict in solidList" :key="dict.id" :label="dict.itemValue" :value="dict.itemValue" />
        </px-select>
      </px-form-item> -->
      <px-form-item label="固废名称">
        <px-select v-model="queryParams.dictWasteCode" placeholder="请选择固废名称" clearable style="width: 240px" filterable>
          <px-option v-for="dict in solidList" :key="dict.id" :label="dict.itemName" :value="dict.itemValue" />
        </px-select>
      </px-form-item>
      <px-form-item label="运输单位">
        <px-select v-model="queryParams.transportCompanyName" placeholder="请选择运输单位" clearable style="width: 240px" filterable>
          <px-option v-for="dict in receiveCompanyNameList" :key="dict.id" :label="dict.itemName" :value="dict.itemName" />
        </px-select>
      </px-form-item>
      <px-form-item label="接收单位">
        <px-select v-model="queryParams.receiveCompanyName" placeholder="请选择接收单位" clearable style="width: 240px" filterable>
          <px-option v-for="dict in receiveCompanyNameList" :key="dict.id" :label="dict.itemName" :value="dict.itemName" />
        </px-select>
      </px-form-item>
      <px-form-item label="出厂时间" style="width: 450px !important">
        <px-date-picker
          v-model="dateRange"
          type="daterange"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD HH:mm:ss"
          :default-time="defaultTime"
        />
      </px-form-item>
      <px-button style="margin-top: -17px" type="primary" icon="" @click="handleQuery('search')">搜索</px-button>
      <px-button style="margin-top: -17px" icon="" @click="resetQuery">重置</px-button>
    </px-form>

    <px-row :gutter="10" class="mb8">
      <px-col :span="1.5">
        <px-button v-has="'GENERAL_WASTE_ADD'" type="primary" icon="" @click="handleAdd">新增</px-button>
      </px-col>
      <px-col :span="1.5">
        <px-button v-has="'GENERAL_WASTE_EXPORT'" type="primary" plain icon="" @click="handleExport">导出报表</px-button>
      </px-col>

      <px-col :span="1.5">
        <px-button v-has="'GENERAL_WASTE_DELETE'" type="danger" plain icon="" :disabled="multiple" @click="handlebatchDelete">删除</px-button>
      </px-col>
    </px-row>

    <px-table
      v-if="!equipopen && !equipopenDetail"
      v-loading="loading"
      :data="typeList"
      height="calc(100vh - 369px)"
      show-overflow-tooltip
      border
      @selection-change="handleSelectionChange"
    >
      <px-table-column label="序号" width="60" align="center" fixed="left">
        <template #default="{ $index }">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + $index + 1 }}
        </template>
      </px-table-column>
      <px-table-column label="固废代码" prop="wasteCode">
        <template #default="scope">
          <span>{{ scope.row.wasteCode }}</span>
        </template>
      </px-table-column>

      <px-table-column label="固废名称" prop="wasteCode">
        <template #default="scope">
          <span>{{ scope.row.wasteName }}</span>
        </template>
      </px-table-column>

      <px-table-column label="出厂时间" width="160" prop="outFactoryTime">
        <template #default="scope">
          <span>{{ scope.row.outFactoryTime }}</span>
        </template>
      </px-table-column>

      <px-table-column label="出厂数量(吨)" prop="quantity">
        <template #default="scope">
          <span>{{ scope.row.quantity }}</span>
        </template>
      </px-table-column>
      <px-table-column label="运输单位" prop="transportCompanyName">
        <template #default="scope">
          <span>{{ scope.row.transportCompanyName }}</span>
        </template>
      </px-table-column>
      <px-table-column label="槽车车号" prop="carNumber">
        <template #default="scope">
          <span>{{ scope.row.carNumber }}</span>
        </template>
      </px-table-column>
      <px-table-column label="接收单位" prop="receiveCompanyName">
        <template #default="scope">
          <span>{{ scope.row.receiveCompanyName }}</span>
        </template>
      </px-table-column>
      <px-table-column label="出厂环节经办人(科)" width="160" prop="outFactoryClassOperatorName">
        <template #default="scope">
          <span>{{ scope.row.outFactoryClassOperatorName }}</span>
        </template>
      </px-table-column>
      <px-table-column label="出厂环节经办人(外服)" width="180" prop="outFactoryExternalOperatorName">
        <template #default="scope">
          <span>{{ scope.row.outFactoryExternalOperatorName }}</span>
        </template>
      </px-table-column>
      <px-table-column label="出库日期" width="160" prop="outFactoryTime">
        <template #default="scope">
          <span>{{ scope.row.outFactoryDate ? scope.row.outFactoryDate.slice(0, 10) : "-" }}</span>
        </template>
      </px-table-column>
      <px-table-column label="操作" align="center" width="240">
        <template #default="scope">
          <px-button v-has="'GENERAL_WASTE_COPY'" link type="primary" @click="handleCopy(scope.row.id)">
            <px-tooltip class="box-item" content="复制" placement="top">
              <px-icon><CopyDocument /></px-icon> </px-tooltip
          ></px-button>
          <px-button v-has="'GENERAL_WASTE_FORECAST'" link type="primary" @click="handleForecast(scope.row.id)">
            <px-tooltip class="box-item" content="预测" placement="top">
              <px-icon>
                <Histogram />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-has="'GENERAL_WASTE_DETAIL'" link type="primary" @click="handleDetail(scope.row.id)">
            <px-tooltip class="box-item" content="详情" placement="top">
              <px-icon>
                <Tickets />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="scope.row.status != 'INVALID'" v-has="'GENERAL_WASTE_DEITOR'" link type="primary" @click="handleEditor(scope.row.id)">
            <px-tooltip class="box-item" content="编辑" placement="top">
              <px-icon>
                <EditPen />
              </px-icon> </px-tooltip
          ></px-button>
          <px-button v-if="scope.row.status != 'INVALID'" v-has="'GENERAL_WASTE_LISTDELETE'" link type="danger" @click="handleDelete(scope.row)"
            ><px-tooltip class="box-item" content="删除" placement="top">
              <px-icon>
                <Delete />
              </px-icon> </px-tooltip
          ></px-button>
        </template>
      </px-table-column>
      <template #empty>
        <px-empty :image-size="150" />
      </template>
    </px-table>

    <pagination
      v-if="!equipopen && !equipopenDetail"
      v-show="total > 0"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      style="margin-bottom: -10px"
      :total="total"
      @pagination="getList"
    />

    <!-- 添加或修改参数配置对话框 -->

    <px-scrollbar v-if="equipopen" class="editorEquip">
      <px-button style="margin-left: 24px" type="primary" :icon="ArrowLeft" @click="cancel">返回</px-button>
      <px-descriptions style="padding: 20px" class="margin-top" title="一般固废委外台账详情" :column="3" border>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">固废名称:</div>
          </template>
          {{ equipdata.wasteName }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">固废代码:</div>
          </template>
          {{ equipdata.wasteCode }}
        </px-descriptions-item>
        <!-- <px-descriptions-item>
          <template #label>
            <div class="cell-item">已委外数量:</div>
          </template>
          {{ equipdata.neededQuantity }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">剩余委外数量:</div>
          </template>
          {{ equipdata.surplusNeedQuantity }}
        </px-descriptions-item> -->
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">接收厂商:</div>
          </template>
          {{ equipdata.receiveCompanyName }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">委外数量（吨）:</div>
          </template>
          {{ equipdata.needQuantity }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">运输单位:</div>
          </template>
          {{ equipdata.transportCompanyName }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">出厂时间:</div>
          </template>
          {{ equipdata.outFactoryTime }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">出厂数量(吨):</div>
          </template>
          {{ equipdata.quantity }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">槽车车号:</div>
          </template>
          {{ equipdata.carNumber }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">检查人:</div>
          </template>
          {{ equipdata.outFactoryClassOperatorName }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">厂商负责人:</div>
          </template>
          {{ equipdata.outFactoryExternalOperatorName }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">司机:</div>
          </template>
          {{ equipdata.driverName }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">最后更新时间:</div>
          </template>
          {{ equipdata.updateTime }}
        </px-descriptions-item>
        <px-descriptions-item>
          <template #label>
            <div class="cell-item">描述:</div>
          </template>
          {{ equipdata.description }}
        </px-descriptions-item>
      </px-descriptions>
      <div style="width: 100%; padding: 0 0 0 20px; clear: both">
        <div class="px-descriptions__title" style="padding: 20px 0">检查核对事项</div>
        <div v-for="(item, index) in equipdata.checkResult.group" :key="index" class="info-form-content">
          <modelTitle :title="item.checkStep" style="margin: 16px 0" />
          <px-table :data="item.details" show-overflow-tooltip border style="width: 100%">
            <px-table-column type="index" width="60" label="序号" />
            <px-table-column prop="content" label="检查项" />
            <px-table-column label="检查结果" align="center">
              <template #default="scope">
                <px-radio-group v-model="scope.row.label" class="ml-4">
                  <px-radio v-for="item in scope.row.options" :key="item.label" disabled="true" :label="item.label" size="large">{{
                    item.label
                  }}</px-radio>
                </px-radio-group>
              </template>
            </px-table-column>
            <px-table-column label="要求图片">
              <template #default="scope">
                <span>{{ scope.row.needPicture != "N" ? scope.row.pictureName : "-" }}</span>
              </template>
            </px-table-column>
            <px-table-column label="图片">
              <template #default="scope">
                <PhotoUploadchem v-if="scope.row.updatePictures != null" photoType="view" :photoList2="scope.row.updatePictures" />
                <span v-else>-</span>
              </template>
            </px-table-column>
            <px-table-column label="AI图像识别结果">
              <template #default="scope">
                <span style="float: left; margin-right: 10px">{{ scope.row.aiRecognitionResult ? scope.row.aiRecognitionResult : "-" }}</span>
                <PhotoUploadchem
                  v-if="scope.row.aiPictureUrls != null"
                  photoType="view"
                  :photoList2="
                    scope.row.aiPictureUrls.map(item => {
                      return {
                        url: item
                      };
                    })
                  "
                />
              </template>
            </px-table-column>
          </px-table>
        </div>
      </div>
      <div style="width: 100%; padding: 0 0 0 20px; clear: both">
        <div class="px-descriptions__title">过磅照片</div>
        <PhotoUpload photoType="view" :photoData="{ moduleName: 'OPERATION_WATER' }" :photoList="equipdata.weighingFile" />
      </div>
      <div style="width: 100%; padding: 20px; clear: both">
        <div class="px-descriptions__title">附件</div>
        <FileUpload fileType="view" :fileData="{ moduleName: 'OPERATION_WATER' }" :fileList="equipdata.attachment" />
      </div>
    </px-scrollbar>
    <px-scrollbar v-if="equipopenDetail" class="addEquip">
      <px-button style="margin-left: 24px" type="primary" :icon="ArrowLeft" @click="equipopenDetailcancel">返回</px-button>
      <px-steps :active="active" finish-status="success" style="width: 300px; margin: 0 auto; margin-top: 10px">
        <px-step title="联系厂商" />
        <px-step title="现场载出" />
      </px-steps>
      <px-form
        ref="detailruleFormRef"
        :disabled="fromdisable"
        :rules="active == 0 ? rules0 : rules"
        :model="equipdata"
        :inline="true"
        class="demo-form-inline"
        label-width="160px"
      >
        <div v-if="active == 0">
          <div
            class="box-card1"
            :style="{
              height: changshangFlg == true ? '' : '42px'
            }"
          >
            <div class="card-header" @click="setchangshangFlg()">
              <div class="card-title">联系厂商</div>
              <div class="card-main">
                <px-icon v-if="!changshangFlg">
                  <ArrowDown />
                </px-icon>
                <px-icon v-else>
                  <ArrowUp />
                </px-icon>
              </div>
            </div>
            <div class="form-div">
              <px-row>
                <px-col :span="8">
                  <px-form-item label="固废名称" prop="dictWasteCode">
                    <px-select
                      v-model="equipdata.dictWasteCode"
                      :disabled="buttonTitle == '编辑'"
                      clearable
                      style="width: calc(100% - 100px)"
                      placeholder="请选择固废名称"
                      @change="setreceiveCompanyCode"
                    >
                      <px-option v-for="dict in solidList" :key="dict.id" :label="dict.itemName" :value="dict.itemValue" />
                    </px-select>
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="委外数量（吨）" prop="needQuantity">
                    <px-input v-model="equipdata.needQuantity" placeholder="请输入" clearable /> </px-form-item
                ></px-col>
                <px-col :span="8">
                  <px-form-item label="接收厂商" prop="receiveCompanyName">
                    <px-select
                      v-model="equipdata.receiveCompanyName"
                      placeholder="请选择接收厂商"
                      clearable
                      style="width: calc(100% - 100px)"
                      filterable
                    >
                      <px-option v-for="dict in receiveCompanyNameList" :key="dict.id" :label="dict.itemName" :value="dict.itemName" />
                    </px-select> </px-form-item
                ></px-col>

                <px-col :span="8">
                  <px-form-item label="到厂时间" prop="supplierArriveTime">
                    <px-date-picker
                      v-model="equipdata.supplierArriveTime"
                      style="width: calc(100% - 100px)"
                      placeholder="请选择到厂时间"
                      type="datetime"
                      format="YYYY-MM-DD HH:mm:ss"
                      value-format="YYYY-MM-DD HH:mm:ss"
                      @change="checkTime"
                    />
                  </px-form-item>
                </px-col>
                <px-col v-if="buttonTitle == '新增'" :span="8">
                  <px-form-item label="已委外数量">
                    <px-input v-model="equipdata.neededQuantity" disabled="true" placeholder="已委外数量" clearable /> </px-form-item
                ></px-col>
                <px-col v-else :span="8">
                  <px-form-item label="已委外数量">
                    <px-input v-model="equipdata.usedQuantity" disabled="true" placeholder="已委外数量" clearable /> </px-form-item
                ></px-col>
                <px-col v-if="buttonTitle == '新增'" :span="8">
                  <px-form-item label="剩余委外数量">
                    <px-input v-model="equipdata.surplusNeedQuantity" disabled="true" placeholder="剩余委外数量" clearable /> </px-form-item
                ></px-col>
                <px-col v-else :span="8">
                  <px-form-item label="剩余委外数量">
                    <px-input v-model="equipdata.remainQuantity" disabled="true" placeholder="剩余委外数量" clearable /> </px-form-item
                ></px-col>
              </px-row>
            </div>
          </div>
        </div>
        <div v-if="active == 1">
          <div
            class="box-card1"
            :style="{
              height: jibenxinxiFlg == true ? '' : '42px'
            }"
          >
            <div class="card-header" @click="setqingdanFlg()">
              <div class="card-title">载出信息</div>
              <div class="card-main">
                <px-icon v-if="!jibenxinxiFlg">
                  <ArrowDown />
                </px-icon>
                <px-icon v-else>
                  <ArrowUp />
                </px-icon>
              </div>
            </div>
            <div class="form-div">
              <px-row>
                <px-col :span="8">
                  <px-form-item label="固废名称" prop="dictWasteCode">
                    <px-select
                      v-model="equipdata.dictWasteCode"
                      :disabled="buttonTitle == '编辑'"
                      clearable
                      style="width: calc(100% - 100px)"
                      placeholder="请选择固废名称"
                      @change="setreceiveCompanyCode"
                    >
                      <px-option v-for="dict in solidList" :key="dict.id" :label="dict.itemName" :value="dict.itemValue" />
                    </px-select>
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="固废代码" prop="wasteCode">
                    <px-input v-model="equipdata.wasteCode" disabled="true" placeholder="选择固废名称自动带入" clearable />
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="接收厂商" prop="receiveCompanyName">
                    <px-select
                      v-model="equipdata.receiveCompanyName"
                      placeholder="请选择接收厂商"
                      clearable
                      style="width: calc(100% - 100px)"
                      filterable
                    >
                      <px-option v-for="dict in receiveCompanyNameList" :key="dict.id" :label="dict.itemName" :value="dict.itemName" />
                    </px-select>
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="运输单位" prop="transportCompanyName">
                    <px-select v-model="equipdata.transportCompanyName" placeholder="运输单位" clearable style="width: calc(100% - 100px)" filterable>
                      <px-option v-for="dict in receiveCompanyNameList" :key="dict.id" :label="dict.itemName" :value="dict.itemName" />
                    </px-select>
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="槽车车号" prop="carNumber">
                    <px-input v-model="equipdata.carNumber" placeholder="请输入槽车车号" clearable /> </px-form-item
                ></px-col>
                <px-col :span="8">
                  <px-form-item label="司机姓名" prop="driverName">
                    <px-input v-model="equipdata.driverName" placeholder="请输入司机姓名" clearable /> </px-form-item
                ></px-col>
                <px-col :span="8">
                  <px-form-item label="出库时间" prop="outFactoryTime">
                    <px-date-picker
                      v-model="equipdata.outFactoryTime"
                      style="width: calc(100% - 100px)"
                      placeholder="请选择出库时间"
                      type="datetime"
                      format="YYYY-MM-DD HH:mm:ss"
                      value-format="YYYY-MM-DD HH:mm:ss"
                      @change="checkTime"
                    />
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="出厂数量(吨)" prop="quantity">
                    <px-input v-model="equipdata.quantity" placeholder="请输入出厂数量(吨)" clearable /> </px-form-item
                ></px-col>
                <px-col :span="8">
                  <px-form-item label="流向类型" prop="flowType">
                    <px-select v-model="equipdata.flowType" style="width: calc(100% - 100px)" placeholder="请选择流向类型">
                      <px-option v-for="dict in flowTypeList" :key="dict.itemName" :label="dict.itemName" :value="dict.itemName" />
                    </px-select>
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="运输方式" prop="transportType">
                    <px-select v-model="equipdata.transportType" style="width: calc(100% - 100px)" placeholder="请选择运输方式">
                      <px-option v-for="dict in transportTypeList" :key="dict.itemName" :label="dict.itemName" :value="dict.itemName" />
                    </px-select>
                  </px-form-item>
                </px-col>
                <px-col :span="8">
                  <px-form-item label="厂商负责人" prop="outFactoryExternalOperatorName">
                    <px-input v-model="equipdata.outFactoryExternalOperatorName" placeholder="请输入厂商负责人" clearable /> </px-form-item
                ></px-col>

                <px-col :span="8">
                  <px-form-item label="检查人" prop="outFactoryClassOperatorId">
                    <px-select
                      v-model="equipdata.outFactoryClassOperatorId"
                      style="width: calc(100% - 100px)"
                      placeholder="请选择检查人"
                      @change="changeoutFactoryClassOperator"
                    >
                      <px-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value" />
                    </px-select>
                  </px-form-item>
                </px-col>
                <px-col :span="24">
                  <px-form-item label="描述" prop="description">
                    <px-input
                      v-model="equipdata.description"
                      style="width: calc(100% - 100px)"
                      :autosize="{ minRows: 5, maxRows: 6 }"
                      type="textarea"
                      placeholder="请输入描述"
                      clearable
                    />
                  </px-form-item>
                </px-col>
              </px-row>
            </div>
          </div>
          <div
            class="box-card2"
            :style="{
              height: heduiFlg == true ? '' : '42px'
            }"
          >
            <div class="card-header" @click="setheduiFlg()">
              <div class="card-title">检查核对事项</div>
              <div class="card-main">
                <px-icon v-if="!heduiFlg">
                  <ArrowDown />
                </px-icon>
                <px-icon v-else>
                  <ArrowUp />
                </px-icon>
              </div>
            </div>
            <px-scrollbar class="form-div">
              <div
                v-for="(item, index) in buttonTitle == '新增' ? checkItemList.group : equipdata.checkResult.group"
                :key="index"
                class="info-form-content"
              >
                <modelTitle :title="item.checkStep" style="margin: 16px 0" />
                <px-table :data="item.details" show-overflow-tooltip border style="width: 100%">
                  <px-table-column type="index" width="60" label="序号" />
                  <px-table-column prop="content" label="检查项" />
                  <px-table-column label="检查结果" align="center">
                    <template #default="scope">
                      <px-radio-group v-model="scope.row.label" class="ml-4">
                        <px-radio v-for="item in scope.row.options" :key="item.label" :label="item.label" size="large">{{ item.label }}</px-radio>
                      </px-radio-group>
                    </template>
                  </px-table-column>
                  <px-table-column label="要求图片">
                    <template #default="scope">
                      <span>{{ scope.row.needPicture != "N" ? scope.row.pictureName : "-" }}</span>
                    </template>
                  </px-table-column>
                  <px-table-column label="图片">
                    <template #default="scope">
                      <PhotoUploadchem
                        v-if="scope.row.needPicture != 'N'"
                        :key="scope.row.checkNumber"
                        photoType="add"
                        :photoList2="scope.row.updatePictures"
                        :row="scope.row"
                        @changePhotoList="changePhotoList2"
                      />
                      <span v-else>-</span>
                    </template>
                  </px-table-column>
                  <px-table-column label="AI图像识别结果">
                    <template #default="scope">
                      <span style="float: left; margin-right: 10px">{{ scope.row.aiRecognitionResult ? scope.row.aiRecognitionResult : "-" }}</span>
                      <PhotoUploadchem
                        v-if="scope.row.aiPictureUrls != null"
                        photoType="view"
                        :photoList2="
                          scope.row.aiPictureUrls.map(item => {
                            return {
                              url: item
                            };
                          })
                        "
                      />
                    </template>
                  </px-table-column>
                </px-table>
              </div>
            </px-scrollbar>
          </div>
          <div
            class="box-card2"
            :style="{
              height: jiqicanshuFlg == true ? '' : '42px'
            }"
          >
            <div class="card-header" @click="setjiqicanshuFlg()">
              <div class="card-title">过磅照片</div>
              <div class="card-main">
                <px-icon v-if="!jiqicanshuFlg">
                  <ArrowDown />
                </px-icon>
                <px-icon v-else>
                  <ArrowUp />
                </px-icon>
              </div>
            </div>
            <px-scrollbar class="form-div">
              <div class="info-form-content">
                <PhotoUpload
                  :key="'ptoto1'"
                  photoType="add"
                  :photoData="{ moduleName: 'OPERATION_WATER' }"
                  :photoList="equipdata.weighingFile"
                  @changePhotoList="changePhotoList"
                  @savePhotoStatus="savePhotoStatus"
                />
              </div>
            </px-scrollbar>
          </div>

          <div
            class="box-card3"
            :style="{
              height: shebeitaizhangFlg == true ? '' : '42px'
            }"
          >
            <div class="card-header" @click="setshebeitaizhangFlg()">
              <div class="card-title">关联文档</div>
              <div class="card-main">
                <px-icon v-if="!shebeitaizhangFlg">
                  <ArrowDown />
                </px-icon>
                <px-icon v-else>
                  <ArrowUp />
                </px-icon>
              </div>
            </div>
            <px-scrollbar class="form-div">
              <div class="info-form-content">
                <FileUpload
                  fileType="add"
                  :fileData="{ moduleName: 'OPERATION_WATER' }"
                  :fileList="equipdata.attachment"
                  @changeFileList="changeFileList"
                  @saveFileStatus="saveFileStatus"
                />
              </div>
            </px-scrollbar>
          </div>
        </div>
      </px-form>
    </px-scrollbar>
    <div v-if="equipopenDetail" v-loading="subLoading" class="px-dialog-footer">
      <px-button @click="equipopenDetailcancel">取消</px-button>
      <px-button v-if="active == 0" type="primary" plain @click="next">下一步</px-button>
      <px-button v-if="active == 1" type="primary" plain @click="last">上一步</px-button>
      <px-button v-if="fromdisable" type="primary" @click="equipopenDetailcancel">关闭</px-button>
      <px-button v-else type="primary" :disabled="photoStatusFlag || fileStatusFlag" @click="equipopenDetailsubmitForm(detailruleFormRef)"
        >保存</px-button
      >
    </div>
    <px-dialog v-model="progressVisible" draggable clickHideContent title="预测" width="950" align-center>
      <px-form class="custom-form-ui">
        <px-form-item label="预测时间" style="float: left; width: 516px !important">
          <px-date-picker
            v-model="ForecastRange"
            type="datetimerange"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            format="YYYY-MM-DD HH:mm:ss"
            value-format="YYYY-MM-DD HH:mm:ss"
            :default-time="defaultTime"
          />
        </px-form-item>
        <px-button style="float: left; margin-top: 0" type="primary" icon="" @click="handleQueryForecast()">搜索</px-button>
      </px-form>
      <chartloadSummary
        :xlist="chartList.map(item => item.date)"
        :chartlist="chartList"
        style="width: 100%; height: 500px"
        :width="'100%'"
        :height="'500px'"
      />
    </px-dialog>
  </div>
</template>

<script setup name="Dict" lang="ts">
import chartloadSummary from "./chartloadSummary.vue";
import Doc from "@/assets/svg/file/doc.svg?component";
import Pdf from "@/assets/svg/file/pdf.svg?component";
import Ppt from "@/assets/svg/file/ppt.svg?component";
import Txt from "@/assets/svg/file/txt.svg?component";
import Xsl from "@/assets/svg/file/xsl.svg?component";
// import useDictStore from '@/store/modules/dict'
defineOptions({
  name: "SystemDataDict"
});
// import { router } from "@/router";
import { ArrowLeft } from "@px-ui/icons-vue";
import { useRoute } from "vue-router";
import { PxMessage, PxMessageBox } from "px-ui";
import { getCurrentInstance, ref, toRefs, reactive, onMounted } from "vue";
import { getToken } from "@/utils/auth";
import PhotoUpload from "@/components/Upload/PhotoUpload.vue";
import PhotoUploadchem from "@/components/Upload/PhotoUploadchem.vue";
import FileUpload from "@/components/Upload/FileUpload.vue";
import { userlistPage } from "@/api/waterQualityDetection";
import modelTitle from "@/views/common/components/modelTitle/index.vue";
import {
  queryChildByTypeCodeAndItemValue,
  getqueryListPage,
  solidAdd,
  solidUpdate,
  solidDelete,
  solidqueryDetail,
  solidFileDelete
} from "@/api/solidity";
import { receiveName2, solidqueryContactUseInfo, solidbatchDelete } from "@/api/waterClass";
import { checkItemqueryList } from "@/api/chemicals";
import { hazardWasteInqueryWasteFuture3 } from "@/api/hazardousWasteS";
const props = defineProps({
  classCode: {
    type: String,
    default: "WATER"
  }
});
const jibenxinxiFlg = ref(true);
const changshangFlg = ref(true);
const defaultTime: [Date, Date] = [new Date(2000, 1, 1, 0, 0, 1), new Date(2000, 1, 1, 23, 59, 59)];
const setqingdanFlg = () => {
  jibenxinxiFlg.value = !jibenxinxiFlg.value;
};
const jiqicanshuFlg = ref(true);
const setjiqicanshuFlg = () => {
  jiqicanshuFlg.value = !jiqicanshuFlg.value;
};
const shebeitaizhangFlg = ref(true);
const setshebeitaizhangFlg = () => {
  shebeitaizhangFlg.value = !shebeitaizhangFlg.value;
};
const heduiFlg = ref(true);
const setheduiFlg = () => {
  heduiFlg.value = !heduiFlg.value;
};
const setchangshangFlg = () => {
  changshangFlg.value = !changshangFlg.value;
};
const moxingshezhiFlg = ref(true);
const active = ref(0);
const next = () => {
  active.value = 1;
};
const last = () => {
  active.value = 0;
};
const handleForecast = id => {
  const end = new Date();
  end.setHours(23, 59, 59, 0);
  end.setTime(end.getTime());
  const start = new Date();
  start.setHours(0, 0, 0, 0);
  start.setTime(start.getTime() + 3600 * 1000 * 24 * 8);
  console.log(id);
  Futureid.value = id;
  hazardWasteInqueryWasteFuture3({
    startDate: formatDate(end),
    endDate: formatDate(start),
    id: id,
    classCode: props.classCode,
    physicalState: "SOLID"
  }).then(res => {
    chartList.value = res.futureData;
    setTimeout(() => {
      progressVisible.value = true;
    }, 200);
  });
};
const handleQueryForecast = () => {
  if (ForecastRange.value.length > 0) {
    hazardWasteInqueryWasteFuture3({
      startDate: ForecastRange.value[0],
      endDate: ForecastRange.value[1],
      id: Futureid.value,
      classCode: props.classCode,
      physicalState: "SOLID"
    }).then(res => {
      chartList.value = res.futureData;
      setTimeout(() => {
        progressVisible.value = true;
      }, 200);
    });
  } else {
    PxMessage({
      message: "请选择预测时间",
      type: "error"
    });
  }
};
const setmoxingshezhiFlg = () => {
  moxingshezhiFlg.value = !moxingshezhiFlg.value;
};

const changeoutFactoryClassOperator = val => {
  userList.value.forEach(item => {
    if (item.value == val) {
      console.log(item);
      equipdata.value.outFactoryClassOperatorName = item.label;
    }
  });
};

const route = useRoute();
onMounted(() => {
  if (route.query.equipmentId) {
    handleDetail(route.query.equipmentId);
  }
});
const { proxy }: any = getCurrentInstance();

const typeList = ref([]);
const detailruleFormRef = ref();
const progressVisible = ref(false);
const open = ref(false);
const equipopen = ref(false);
const equipopenDetail = ref(false);
const fromdisable = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const typeIdloading = ref(false);
const total = ref(0);
const progressPercent = ref(0);
const title = ref("");
const dateRange = ref([]);

// 图片是否上传完，是否可以保存
const savePhotoStatus = val => {
  photoStatusFlag.value = val;
};
// 文件是否上传完，是否可以保存
const saveFileStatus = val => {
  fileStatusFlag.value = val;
};
const setreceiveCompanyCode = val => {
  getContactUseInfo();
  let setvalue = null;
  setvalue = solidList.value.find(option => option.itemValue == val);
  if (setvalue && setvalue?.itemDesc != "") {
    equipdata.value.wasteCode = JSON.parse(setvalue.itemDesc).code;
  } else {
    equipdata.value.wasteCode = "";
  }
  //console.log(setvalue);
};

const waterstatusList = [
  {
    value: "VALID",
    name: "全部"
  },
  {
    value: "INVALID",
    name: "已删除"
  }
];
const buttonTitle = ref("");
const data = reactive({
  solidList: [],
  transportCompanyList: [],
  receiveCompanyList: [],
  typeIdList: [],
  categoryList: [],
  equipmentTypeList: [],
  positionList: [],
  equipmentDeptList: [],
  modelIdList: [],
  form: {},
  photoStatusFlag: false,
  fileStatusFlag: false,
  equipdata: {
    ledgerCode: "",
    wasteCode: "",
    wasteName: "",
    outFactoryTime: "",
    quantity: "",
    transportCompanyCode: "",
    transportCompanyName: "",
    carNumber: "",
    dictWasteCode: "",
    receiveCompanyName: "",
    outFactoryClassOperatorId: "",
    outFactoryClassOperatorName: "",
    outFactoryExternalOperatorName: "",
    driverName: "",
    description: "",
    updateTime: "",
    weighingFile: [],
    attachment: [],
    flowType: "",
    transportType: "",
    needQuantity: "",
    supplierArriveTime: "",
    neededQuantity: "",
    surplusNeedQuantity: "",
    checkResult: {},
    checkVersion: "",
    usedQuantity: "",
    remainQuantity: ""
  },
  queryParams: {
    classCode: props.classCode,
    dictWasteCode: "",
    wasteCode: "",
    wasteName: "",
    transportCompanyName: "",
    receiveCompanyName: "",
    outFactoryClassOperatorName: "",
    status: "VALID",
    requestId: "",
    timeFrom: "",
    timeTo: "",
    orderBy: "",
    pageNum: 1,
    pageSize: 20
  },
  rules0: {
    dictWasteCode: [{ required: true, message: "固废代码或固废名称不能为空", trigger: "change" }],
    needQuantity: [{ required: true, message: "委外数量不能为空", trigger: "blur" }],
    receiveCompanyName: [{ required: true, message: "接收厂商不能为空", trigger: "change" }],
    supplierArriveTime: [{ required: true, message: "到厂时间不能为空", trigger: "blur" }]
  },
  rules: {
    dictWasteCode: [{ required: true, message: "固废代码或固废名称不能为空", trigger: "change" }],
    wasteCode: [{ required: true, message: "固废代码或固废名称不能为空", trigger: "change" }],
    transportCompanyName: [{ required: true, message: "运输单位不能为空", trigger: "change" }],
    receiveCompanyName: [{ required: true, message: "接收单位不能为空", trigger: "change" }],
    outFactoryClassOperatorId: [{ required: true, message: "检查人不能为空", trigger: "change" }],
    driverName: [{ required: true, message: "司机姓名不能为空", trigger: "blur" }],
    outFactoryExternalOperatorName: [{ required: true, message: "厂商负责人不能为空", trigger: "change" }],
    quantity: [{ required: true, message: "出厂数量(吨)不能为空", trigger: "blur" }],
    carNumber: [{ required: true, message: "槽车车号不能为空", trigger: "blur" }],
    outFactoryTime: [{ required: true, message: "出库时间不能为空", trigger: "blur" }],
    flowType: [{ required: true, message: "流向类型不能为空", trigger: "change" }],
    transportType: [{ required: true, message: "运输方式不能为空", trigger: "change" }]
    // description: [{ required: true, message: "描述不能为空", trigger: "blur" }]
  },
  headers: {
    Authorization: "Bearer " + getToken().accessToken || ""
  },
  moduleName: "",
  dialogImageUrl: "",
  imageVisible: false,
  flowTypeList: [],
  transportTypeList: [],
  userList: [],
  checkItemList: {},
  chartList: [],
  ForecastRange: [],
  Futureid: "",
  receiveCompanyNameList: []
});

const {
  receiveCompanyNameList,
  chartList,
  ForecastRange,
  Futureid,
  checkItemList,
  userList,
  flowTypeList,
  transportTypeList,
  solidList,
  transportCompanyList,
  receiveCompanyList,
  queryParams,
  form,
  rules0,
  rules,
  equipdata,
  typeIdList,
  equipmentTypeList,
  modelIdList,
  dialogImageUrl,
  imageVisible,
  photoStatusFlag,
  fileStatusFlag
} = toRefs(data);
const handleRemove = file => {
  equipdata.value.attachment = equipdata.value.attachment.filter(item => item !== file);
  let parmas = {
    fileId: file.fileId ? file.fileId : file?.response?.data?.fileId,
    ledgerCode: equipdata.value.ledgerCode
  };
  solidFileDelete(parmas).then((response: any) => {
    // //console.log(response);
    PxMessage({
      type: "success",
      message: "删除成功"
    });
  });
};
const getContactUseInfo = () => {
  if (equipdata.value.supplierArriveTime && equipdata.value.dictWasteCode) {
    solidqueryContactUseInfo({
      classCode: props.classCode,
      dictWasteCode: equipdata.value.dictWasteCode,
      physicalState: "LIQUID",
      date: equipdata.value.supplierArriveTime
    }).then(res => {
      console.log(res);
      if (res) {
        equipdata.value.neededQuantity = res.usedQuantity;
        equipdata.value.surplusNeedQuantity = res.remainQuantity;
      }
    });
  }
};
const checkTime = () => {
  getContactUseInfo();
  if (equipdata.value.manufactureDate && equipdata.value.warrantyEndDate) {
    if (equipdata.value.manufactureDate > equipdata.value.warrantyEndDate) {
      PxMessage({
        message: "开始时间不能大于结束时间",
        type: "error"
      });
    }
  }
};
function handlebatchDelete() {
  //console.log(row);
  // const dictIds = [];
  // if (row.equipmentId != undefined) {
  //   dictIds.push(row.equipmentId);
  // } else {
  //   dictIds.push(...ids.value);
  // }
  PxMessageBox.confirm("是否确认删除？", "温馨提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
    draggable: true
  })
    .then(async () => {
      const data = await solidbatchDelete({ ids: ids.value });
      PxMessage({
        message: "删除成功",
        type: "success"
      });
      getList();
    })
    .catch(() => {});
}
function formatDate(date) {
  const year = date.getFullYear();
  const month = (date.getMonth() + 1).toString().padStart(2, "0");
  const day = date.getDate().toString().padStart(2, "0");
  const h = date.getHours().toString().padStart(2, "0");
  const m = date.getMinutes().toString().padStart(2, "0");
  const s = date.getSeconds().toString().padStart(2, "0");
  return `${year}-${month}-${day} ${h}:${m}:${s}`;
}
const getqueryCategoryList = () => {
  checkItemqueryList({
    type: "WASTE_SOLID"
  }).then(res => {
    console.log(res);
    checkItemList.value = res;
  });
  userlistPage({ page: 1, pageSize: 9999, deptNameList: ["WATER"], status: 0 }).then((response: any) => {
    userList.value = response.data.map(item => ({ label: `${item.username}-${item.realName}`, value: item.userId }));
    console.log(response);
  });
  queryChildByTypeCodeAndItemValue({
    value: "RU01",
    typeCode: "WTTS"
  }).then((response: any) => {
    //console.log(response);
    receiveCompanyNameList.value = response;
  });
  queryChildByTypeCodeAndItemValue({
    value: "FLOW_TYPE",
    typeCode: "WTTS"
  }).then((response: any) => {
    //console.log(response);
    flowTypeList.value = response;
  });
  queryChildByTypeCodeAndItemValue({
    value: "TRANSPORT_TYPE",
    typeCode: "WTTS"
  }).then((response: any) => {
    //console.log(response);
    transportTypeList.value = response;
  });
  // queryChildByTypeCodeAndItemValue({
  //   value: "WI01",
  //   typeCode: "WTTS"
  // }).then((response: any) => {
  //   //console.log(response);
  //   solidList.value = response;
  // });
  //固废代码
  receiveName2({
    classCode: props.classCode,
    physicalState: "SOLID "
  }).then((response: any) => {
    //console.log(response);
    solidList.value = response;
  });
  //运输单位
  // queryChildByTypeCodeAndItemValue({
  //   value: "TU01",
  //   typeCode: "WTTS"
  // }).then((response: any) => {
  //   //console.log(response);
  //   transportCompanyList.value = response;
  // });
  //接收单位
  // queryChildByTypeCodeAndItemValue({
  //   value: "RU01",
  //   typeCode: "WTTS"
  // }).then((response: any) => {
  //   //console.log(response);
  //   receiveCompanyList.value = response;
  // });
  getList();
};
getqueryCategoryList();
function getList() {
  loading.value = true;
  if (dateRange.value != null) {
    queryParams.value.timeFrom = dateRange.value[0];
    queryParams.value.timeTo = dateRange.value[1];
  } else {
    queryParams.value.timeFrom = "";
    queryParams.value.timeTo = "";
  }

  getqueryListPage(queryParams.value).then((response: any) => {
    typeList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}

/** 取消按钮 */
function cancel() {
  equipopen.value = false;
}
function equipopenDetailcancel() {
  equipopenDetail.value = false;
}
/** 表单重置 */
function reset() {
  form.value = {
    id: undefined,
    dictionaryName: undefined,
    dictionaryType: undefined,
    status: "VALID",
    remarks: undefined
  };
  proxy.resetForm("dictRef");
}
/** 搜索按钮操作 */
function handleQuery(type) {
  if (type == "search") {
    queryParams.value.pageNum = 1;
  }
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  queryParams.value = {
    pageNum: queryParams.value.pageNum,
    pageSize: queryParams.value.pageSize,
    classCode: props.classCode,
    dictWasteCode: "",
    wasteCode: "",
    wasteName: "",
    transportCompanyName: "",
    receiveCompanyName: "",
    outFactoryClassOperatorName: "",
    status: "VALID",
    requestId: "",
    timeFrom: "",
    timeTo: "",
    orderBy: ""
  };
  dateRange.value = [];
  handleQuery("reset");
}

/** 新增按钮操作 */
function handleAdd() {
  active.value = 0;
  buttonTitle.value = "新增";
  jibenxinxiFlg.value = true;
  jiqicanshuFlg.value = true;
  shebeitaizhangFlg.value = true;
  moxingshezhiFlg.value = true;
  equipopenDetail.value = true;
  fromdisable.value = false;
  equipmentTypeList.value = [];
  modelIdList.value = [];
  equipdata.value = {
    ledgerCode: "",
    wasteCode: "",
    wasteName: "",
    outFactoryTime: "",
    quantity: "",
    transportCompanyCode: "",
    transportCompanyName: "",
    carNumber: "",
    dictWasteCode: "",
    receiveCompanyName: "",
    outFactoryClassOperatorId: "",
    outFactoryClassOperatorName: "",
    outFactoryExternalOperatorName: "",
    driverName: "",
    description: "",
    updateTime: "",
    weighingFile: [],
    attachment: [],
    flowType: "",
    transportType: "",
    needQuantity: "",
    supplierArriveTime: "",
    neededQuantity: "",
    surplusNeedQuantity: "",
    usedQuantity: "",
    remainQuantity: ""
  };
  checkItemqueryList({
    type: "WASTE_SOLID"
  }).then(res => {
    console.log(res);
    checkItemList.value = res;
  });
}
const handleDetail = async val => {
  active.value = 0;
  jibenxinxiFlg.value = true;
  jiqicanshuFlg.value = true;
  shebeitaizhangFlg.value = true;
  moxingshezhiFlg.value = true;
  const data = await solidqueryDetail({ id: val });
  //console.log(data);

  equipopen.value = true;
  // equipopenDetail.value = true;
  fromdisable.value = true;
  equipdata.value = data;
  if (data.outFactoryClassOperatorId != "") {
    equipdata.value.outFactoryClassOperatorId = Number(data.outFactoryClassOperatorId);
  }
  equipdata.value.checkResult.group = JSON.parse(data.checkResult.group);
  if (data?.weighingFile && data?.weighingFile.length > 0) {
    data?.weighingFile.forEach(item => {
      item.url = item.fileUrl;
    });
    equipdata.value.weighingFile = data?.weighingFile;
  } else {
    equipdata.value.weighingFile = [];
  }
  if (data.attachment && data.attachment.length > 0) {
    data.attachment.forEach(item => {
      item.url = item.fileUrl;
      item.name = item.originalName;
    });
    equipdata.value.attachment = data.attachment;
  } else {
    equipdata.value.attachment = [];
  }
  //console.log(equipdata);
};

const handleCopy = async val => {
  active.value = 0;
  buttonTitle.value = "新增";
  jibenxinxiFlg.value = true;
  jiqicanshuFlg.value = true;
  shebeitaizhangFlg.value = true;
  moxingshezhiFlg.value = true;

  const data = await solidqueryDetail({ id: val });
  //console.log(data);
  equipopenDetail.value = true;
  fromdisable.value = false;
  equipdata.value = data;
  if (data.outFactoryClassOperatorId != "") {
    equipdata.value.outFactoryClassOperatorId = Number(data.outFactoryClassOperatorId);
  }
  equipdata.value.checkResult.group = JSON.parse(data.checkResult.group);
  if (data?.weighingFile && data?.weighingFile.length > 0) {
    data?.weighingFile.forEach(item => {
      item.url = item.fileUrl;
    });
    equipdata.value.weighingFile = data?.weighingFile;
  } else {
    equipdata.value.weighingFile = [];
  }
  if (data.attachment && data.attachment.length > 0) {
    data.attachment.forEach(item => {
      item.url = item.fileUrl;
      item.name = item.originalName;
    });
    equipdata.value.attachment = data.attachment;
  } else {
    equipdata.value.attachment = [];
  }
  equipdata.value.supplierArriveTime = "";
  equipdata.value.outFactoryTime = "";
};

const handleEditor = async val => {
  active.value = 0;
  buttonTitle.value = "编辑";
  jibenxinxiFlg.value = true;
  jiqicanshuFlg.value = true;
  shebeitaizhangFlg.value = true;
  moxingshezhiFlg.value = true;

  const data = await solidqueryDetail({ id: val });
  //console.log(data);
  equipopenDetail.value = true;
  fromdisable.value = false;
  equipdata.value = data;
  if (data.outFactoryClassOperatorId != "") {
    equipdata.value.outFactoryClassOperatorId = Number(data.outFactoryClassOperatorId);
  }
  equipdata.value.checkResult.group = JSON.parse(data.checkResult.group);
  if (data?.weighingFile && data?.weighingFile.length > 0) {
    data?.weighingFile.forEach(item => {
      item.url = item.fileUrl;
    });
    equipdata.value.weighingFile = data?.weighingFile;
  } else {
    equipdata.value.weighingFile = [];
  }
  if (data.attachment && data.attachment.length > 0) {
    data.attachment.forEach(item => {
      item.url = item.fileUrl;
      item.name = item.originalName;
    });
    equipdata.value.attachment = data.attachment;
  } else {
    equipdata.value.attachment = [];
  }
};
/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
// 新的图片列表
const changePhotoList = val => {
  equipdata.value.weighingFile = val;
  console.log(val);
};
const changePhotoList2 = (val, row) => {
  if (row) {
    console.log(val, row);
    row.updatePictures = val.map(item => (item?.response?.data ? item?.response?.data : item));
    console.log(row.updatePictures);
    row.aiRecognitionUid = Date.now();
    console.log(row.aiRecognitionUid);
  }
};
// 新的文件列表
const changeFileList = val => {
  equipdata.value.attachment = val;
  console.log(val);
};
/** 提交按钮 */
const subLoading = ref(false);
const equipopenDetailsubmitForm = async (formEl: any) => {
  if (!formEl) return;
  await formEl.validate(async valid => {
    if (valid) {
      subLoading.value = true;
      const params = {
        id: equipdata.value.id,
        step: active.value == 0 ? "contact" : "load",
        ledgerCode: equipdata.value.ledgerCode,
        wasteCode: equipdata.value.wasteCode,
        wasteName: equipdata.value.wasteName,
        outFactoryTime: equipdata.value.outFactoryTime,
        quantity: equipdata.value.quantity,
        transportCompanyCode: equipdata.value.transportCompanyCode,
        transportCompanyName: equipdata.value.transportCompanyName,
        carNumber: equipdata.value.carNumber,
        dictWasteCode: equipdata.value.dictWasteCode,
        receiveCompanyName: equipdata.value.receiveCompanyName,
        outFactoryClassOperatorId: equipdata.value.outFactoryClassOperatorId,
        outFactoryClassOperatorName: equipdata.value.outFactoryClassOperatorName,
        outFactoryExternalOperatorName: equipdata.value.outFactoryExternalOperatorName,
        driverName: equipdata.value.driverName,
        description: equipdata.value.description,
        weighingFile: equipdata.value.weighingFile,
        attachment: equipdata.value.attachment,
        flowType: equipdata.value.flowType,
        transportType: equipdata.value.transportType,
        updateTime: equipdata.value.updateTime,
        needQuantity: equipdata.value.needQuantity,
        supplierArriveTime: equipdata.value.supplierArriveTime,
        neededQuantity: equipdata.value.neededQuantity,
        surplusNeedQuantity: equipdata.value.surplusNeedQuantity,
        usedQuantity: equipdata.value.neededQuantity,
        remainQuantity: equipdata.value.surplusNeedQuantity,
        classCode: props.classCode,
        checkResult: { group: "" },
        checkVersion: ""
      };
      if (buttonTitle.value == "新增") {
        params.checkResult.group = JSON.stringify(checkItemList.value.group);
        params.checkVersion = checkItemList.value.checkVersion;
        if (params.weighingFile.length > 0) {
          params.weighingFile = params.weighingFile.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }
        if (params.attachment.length > 0) {
          params.attachment = params.attachment.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }
        solidAdd(params)
          .then((response: any) => {
            PxMessage({
              message: `${buttonTitle.value == "新增" ? "添加成功" : "修改成功"}`,
              type: "success"
            });
            getList();
            subLoading.value = false;
            equipopenDetail.value = false;
          })
          .catch(() => {
            subLoading.value = false;
          });
      } else {
        params.checkResult.group = JSON.stringify(equipdata.value.checkResult.group);
        params.checkVersion = equipdata.value.checkVersion;
        console.log(params.weighingFile);
        if (params.weighingFile.length > 0) {
          params.weighingFile = params.weighingFile.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }
        if (params.attachment.length > 0) {
          params.attachment = params.attachment.map(item => (item?.response?.data ? item?.response?.data.id : item.id));
        }
        solidUpdate(params)
          .then((response: any) => {
            PxMessage({
              message: `${buttonTitle.value == "新增" ? "添加成功" : "修改成功"}`,
              type: "success"
            });
            getList();
            subLoading.value = false;
            equipopenDetail.value = false;
          })
          .catch(() => {
            subLoading.value = false;
          });
      }
    }
  });
};
/** 删除按钮操作 */
function handleDelete(row) {
  //console.log(row);
  // const dictIds = [];
  // if (row.equipmentId != undefined) {
  //   dictIds.push(row.equipmentId);
  // } else {
  //   dictIds.push(...ids.value);
  // }
  PxMessageBox.confirm("是否确认删除？", "温馨提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
    draggable: true
  })
    .then(async () => {
      const data = await solidDelete({ id: row.id });
      PxMessage({
        message: "删除成功",
        type: "success"
      });
      getList();
    })
    .catch(() => {});
}

const { VITE_FANRUAN_BASE_URL, VITE_SERVE_API_STATIC_URL } = import.meta.env;
/** 导出按钮操作 */
function handleExport() {
  console.log(dateRange.value);
  if (dateRange.value != null && dateRange.value.length > 0) {
    let Token = getToken().accessToken || "";
    // proxy.download("post", "/operation/api/v1/water/testQuality/pwMetalImpurity/export", queryParams.value, "水质检测-纯水金属阴阳离子.xlsx");
    let url = `${VITE_FANRUAN_BASE_URL}/webroot/decision/view/report?viewlet=water%252F%25E4%25B8%2580%25E8%2588%25AC%25E5%25B7%25A5%25E4%25B8%259A%25E5%259B%25BA%25E4%25BD%2593%25E5%25BA%259F%25E7%2589%25A9%25E5%25A4%2596%25E8%25BD%25BD%25E8%25AE%25B0%25E5%25BD%2595%25E5%258F%25B0%25E8%25B4%25A6.cpt&token=${Token}&from=${dateRange.value[0]}&to=${dateRange.value[1]}&wasteCode=${queryParams.value.wasteCode}&format=excel&extype=simple&classCode=${props.classCode}&facCode=${localStorage.getItem("facCode") || ""}&apiHost=${VITE_SERVE_API_STATIC_URL}`;
    window.location.href = url;
  } else {
    PxMessage({
      message: "请选择时间后再导出",
      type: "error"
    });
  }
}
</script>
<style scoped lang="scss">
.addEquip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 99;
  width: calc(100% - 48px);
  height: calc(100% - 40px);
  padding-top: 10px;
  margin: 24px;
  background: white;
}

.editorEquip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 99;
  width: calc(100% - 48px);
  height: calc(100% - 40px);
  padding-top: 10px;
  margin: 24px;
  background: white;
}

.px-dialog-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 2002;
  width: 100%;
  height: 50px;
  padding-top: 10px;
  padding-right: 34px;
  text-align: right;
  background: white;
  box-shadow: 0 0 10px 0 rgb(0 0 0 / 16%);
}

.card-header {
  min-height: 40px;
  padding: 14px 15px 7px !important;
  cursor: pointer;
  user-select: none;
  background: #e7eefb;
}

.card-title {
  float: left;
  line-height: 14px;
}

.card-main {
  float: left;
  margin: -3px 8px 0 5px;
  cursor: pointer;
}

.box-card1 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card2 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card3 {
  width: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.box-card4 {
  width: calc(100% - 48px);
  height: 261px;
  margin: 24px;
  overflow: hidden;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
}

.demo-form-inline {
  .px-input {
    --px-input-width: calc(100% - 100px);
  }

  .px-form-item {
    width: 100%;
  }

  .px-textarea__inner {
    width: calc(100% - 100px) !important;
  }

  .px-form-item__label {
    font-weight: 400 !important;
  }
}

.form-div {
  padding: 24px;

  .px-row {
    margin-bottom: 16px;
  }
}

.px-icon {
  font-size: 16px !important;
}

:deep(.px-tabs__header) {
  // padding-left: 6px !important;
}

:deep(.px-tabs--top .px-tabs__item.is-top.is-active) {
  border: none;

  .pane-bottom {
    line-height: 30px;
    border-bottom: 2px solid #3b82f6;
  }
}

:deep(.px-tabs .px-tabs__item) {
  .pane-bottom {
    line-height: 30px;
  }
}

.pane-line {
  position: absolute;
  top: 12px;
  right: 0;
  height: 15px;
  color: #dcdcdc;
  border-left: 1px solid #dcdcdc;
}

:deep(.custom-form-ui .px-form-item) {
  width: 250px !important;
}

:deep(.px-upload) {
  --px-upload-dragger-padding-horizontal: 18px;
}

:deep(.px-upload--picture-card) {
  --px-upload-picture-card-size: 93px;

  position: absolute;
}

.file-upload-dom {
  :deep(.px-upload-list--picture-card .px-upload-list__item) {
    position: relative;
    width: 96px;
    height: 96px;
    overflow: visible;

    .filebg {
      position: absolute;
      display: none;
      width: 96px;
      height: 96px;
      background: #0006;
    }

    .filedelect {
      margin: 35px;
      font-size: 22px !important;
      color: white;
      cursor: pointer;
    }

    &:hover {
      .filebg {
        display: block;
      }
    }

    .filesvg {
      position: absolute;
      top: 30px;
      left: 30px;
      font-size: 70px;
    }
  }

  :deep(.px-upload--picture-card) {
    --px-upload-picture-card-size: 93px;

    border: none;
  }
}

:deep(.px-upload-list--picture-card .px-upload-list__item) {
  width: 96px;
  height: 96px;
}

.filename {
  position: absolute;
  bottom: -30px;
  width: 96px;
  overflow: hidden;
  color: rgb(166 167 172);
  text-overflow: ellipsis;
  white-space: nowrap;
}

:deep(.px-descriptions__label.px-descriptions__cell.is-bordered-label) {
  width: 166px;
  background: #e7eefb;
  border: 1px solid #dfdfdf;
}

:deep(.px-descriptions__body .px-descriptions__table.is-bordered .px-descriptions__cell) {
  border: 1px solid #dfdfdf;
}

.cell-item {
  text-align: right;
}

:deep(.px-table__header) {
  thead {
    tr {
      background-color: #e7eefb !important;

      th {
        font-size: 14px;
        font-weight: bold;
        color: #000;
        background-color: #e7eefb !important;
      }

      // th:nth-child(2) {
      //   font-size: 14px;
      //   font-weight: bold;
      //   color: #000;
      //   border-right: none;
      //   background-image: linear-gradient(to right, red, blue);
      // }
      // th:nth-child(3) {
      //   font-size: 14px;
      //   font-weight: bold;
      //   color: #000;
      //   border-right: none;
      //   background-image: linear-gradient(to right, #0400fc, yellow);
      // }
    }
  }
}

:deep(.px-table--isfixedHeader .px-table__header-wrapper .px-table-fixed-column--right) {
  background-color: #e7eefb !important;
}

:deep(.px-upload-list--picture-card > li:first-of-type) {
  margin-left: 104px;
}

:deep(.px-upload-list--picture-card) {
  min-height: 100px;
}

:deep(.px-table) {
  td.px-table__cell,
  .px-table th.px-table__cell.is-leaf {
    position: revert;
  }
}
</style>
